//
//  RTJNetWork.h
//  RuiTaiJinProject
//
//  Created by jayson on 2018/11/26.
//  Copyright © 2018年 leewei. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

typedef enum : NSUInteger {
    POST,
    GET,
    DELETE,
} RequestMethod;

/**content：接口返回的原始数据
 * code:    从接口解析的状态码
 * success: true:接口访问成功（不代表code = 0） false 接口访问失败
 * errorMsg: 接口错误信息，取值于接口msg字段
 */
typedef void(^RequestCompletion)(id data,NSInteger status,BOOL success,NSString * errorMsg);

typedef void(^ZXEmptyCallBack)(void);
typedef void(^ZXStatusCallBack)(BOOL, NSString *);

@interface RTJNetWork : NSObject

///**统一接口数据处理*/
+ (void)commonProcess:(id)content zxCompletion:(RequestCompletion)zxCompletion;
/**HTTP 请求失败*/
+ (void)httpError:(NSError *)error zxCompletion:(RequestCompletion)zxCompletion;


/**
 *  异步接口请求
 *
 *  @param url          接口地址
 *  @param params       接口参数
 *  @param method       请求方式 GET POST DELETE
 *  @param zxCompletion 接口请求完成回调
 */

+ (NSURLSessionDataTask *)asyncRequestWithURL:(NSString *)url
                                       params:(NSDictionary *)params
                                       method:(RequestMethod)method
                                 zxCompletion:(RequestCompletion)zxCompletion;


/**
 *  图片文件上传
 *
 *  @param resourceURL 资源接口地址
 *  @param images      图片数组
 *  @param params      接口请求参数
 *  @param zxCompletion    请求完成回调
 */

+ (NSURLSessionDataTask *)uploadImageToResourceURL:(NSString *)url
                                            images:(NSArray<NSData *> *)images
                                            params:(NSDictionary *)params
                                      zxCompletion:(RequestCompletion)zxCompletion;

@end

